New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

regex-replace-file

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

regex-replace-file

A simple CLI/Module for regex replacing strings in files & renaming files recursively

  • 2.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

regex-replace

A simple CLI/Module for regex replacing strings in files & renaming files recursively

npm Build Status license

Getting Started

This library can be used both locally as a module or globally as a CLI. Simply choose which you'd like via the install command below.

local: npm install regex-replace

global: npm install -g regex-replace

Code Example

CLI Example

Replace filenames and file contents

regex-replace 'search string' 'replace string' './path/to/recursively/replace'

Replace file content only

regex-replace 'search string' 'replace string' './path/to/recursively/replace' --filecontents

Replace filenames only

regex-replace 'search string' 'replace string' './path/to/recursively/replace' --filenames

Version

regex-replace -v
Module Example
import regexReplace from 'regex-replace';

const searchString = 'string to search for';
const replaceString = 'string to replace with';
const path = './some/path/to/recursively/replace';

const options = {
    filenamesOnly: false, //default
    fileContentsOnly: false //default
};

//promise
regexReplace(searchString, replaceString, path, options)
    .then(() => {
        //do something after successful regex replace
    })
    .catch((err) => {
        //handle errors
    });

//async/await
const doRegexReplace = async function() {
    try {
        await regexReplace(searchString, replaceString, path, options);
    } catch (err) {
        console.error('err > regexReplace > testing', err);
    }
}

//callback (no support for callbacks currently)

Prerequisites

  • Node JS >= 6.x.x
  • Yarn (optional but recommended)

API Reference

CLI Example
  • regex-replace searchString replaceString path
  • Flags:
    • --filename or --filenames For filenames only
    • --filecontent or --filecontents For file contents only
Module Example
regexReplace(searchString, replaceString, path, options)
  • Returns promise
  • Options:
    • filenamesOnly: false default
    • fileContentsOnly: false default

Running the tests

  • Fork or clone
  • cd into regex-replace
  • run yarn or npm install
  • npm test

Contributing

Please read CONTRIBUTING.md for details on code of conduct, and the process for submitting pull requests.

Versioning

SemVer is used for versioning. For the versions available, see the releases on this repository.

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT license.

Acknowledgments

Keywords

FAQs

Package last updated on 29 Nov 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc